* Purpose: To generate descriptive statistics for the info_study data.
* Author: Sadish
* Last Modified: 2021-04-22
* Notes:

version 13

* Inputs **************************************************************
  local data "${is_root}/6_Processed_Data/is_4_4_6_publicData.dta"
  local descriptive "${is_root}/7_Output/is_4_4_1_descriptiveTable.tex"
  local uid "empcode" // variables to uniquely identify individuals
***********************************************************************


clear all
set more off
tempfile box

* Get Clean Data ******************************************************
use "`data'", clear
save `box', replace
***********************************************************************

* Generate Descriptive Statistics *************************************
cap: file close texFile
file open texFile using "`descriptive'", write replace
  
  file write texFile ///
    "\begin{tabular}{a{10.2cm} *{2}{b{1.6cm}}} \toprule % The *{#} repeats the following argument for # columns" _n
  file write texFile ///
    "Variable & Mean & Standard Deviation \\ \midrule" _n
  foreach v of varlist ///
    female age quit edu_hi smartphone hostel memory numeracy distress_bl att {
	local varlab: var lab `v'
	// Variable label to use for table's first row
	su `v'
	local mean = string(r(mean), "%12.2fc")
	local sd = string(r(sd), "%12.2fc")
	file write texFile "`varlab' & `mean' & `sd' \\" _n
  }
  file write texFile "& & \\" _n
  file write texFile "\textbf{Select knowledge:} & & \\" _n
  foreach v of varlist *_des_bl {
	local varlab: var lab `v'
	// Variable label to use for table's first row
	su `v'
	local mean = string(r(mean), "%12.2fc")
	local sd = string(r(sd), "%12.2fc")
	file write texFile "`varlab' & `mean' & `sd' \\" _n
  }
  file write texFile "\bottomrule" _n
  file write texFile "\end{tabular}" _n
  file close texFile
***********************************************************************

* Days between baseline and endline ***********************************
gen days = submitDate_el - submitDate_bl
su days, detail
  di "This assersion is in is_4_4_1_ ."
  assert r(p50) == 19 // minus one is 18
drop days
***********************************************************************
